/*
* Plugin name:jTipsShow
* Design by:jucelin
* Home page:http://jucelin.com/jquery-jtipsshow.html
* Last edit:2012.01.14 11:16
*/
(function($) {
	$.fn.jTipsShow=function(setting){
		var defaults = {
			titleValue: '',//title的默认值
			tipsTag: 'span',//选择器
			tipsTitle: 'title',//显示的内容
			delaytime:500//延时
		};
		var opts = $.extend({},defaults, setting);
	
		var jtipsMouseover=function(e){
			opts.titleValue=$(this).attr(opts.tipsTitle);
			$(this).attr(opts.tipsTitle,"");
			$(this).append("<div id='jtipsdiv' style='position:absolute; left:0; top:0; background:lightyellow; border:1px #888 solid; padding:3px 5px; z-index:999; -moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, .4);-webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, .4);box-shadow: 1px 1px 2px rgba(0, 0, 0, .4); opacity: 0;-moz-opacity: 0;filter: alpha(opacity=0);'>"+opts.titleValue+"</div>");
			var tipsDivLeft=e.pageX-tipsContainLeft+6;
			var tipsDivTop=e.pageY-tipsContainTop+8;
			$("#jtipsdiv").css({"left":tipsDivLeft,"top":tipsDivTop}).animate({opacity: 1},opts.delaytime);
			$(this).mousemove(function(e){
				$("#jtipsdiv").css({"left":e.pageX-tipsContainLeft+6,"top":e.pageY-tipsContainTop+6});
			});
		};
		var jtipsMouseout=function(){
			$(this).attr(opts.tipsTitle,opts.titleValue);
			$("#jtipsdiv").remove();
		};
		$(this).css("position","relative");
		var tipsContainLeft=$(this).offset()==null?0:$(this).offset().left;
		var tipsContainTop=$(this).offset()==null?0:$(this).offset().top;
		var infos=$(this).find(opts.tipsTag+"["+opts.tipsTitle+"]");
		$(infos).each(function(){
			$(this).hover(jtipsMouseover,jtipsMouseout);
		});
	}
})(jQuery);